package com.leyou;

import com.leyou.common.constant.PageResult;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient("item-service")
public interface ItemClient {
    //根据分类查找商品---分页查询商品SPU信息
    @GetMapping("/spu/page")
    public PageResult<SpuDTO> goodsPageQuery(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                             @RequestParam(value = "rows", defaultValue = "5") Integer rows,
                                             @RequestParam(value = "key", required = false) String key,
                                             @RequestParam(value = "saleable", required = false) Boolean saleable);
    //根据spu的id查询spuDetail对象
    @GetMapping("/spu/detail")
    public SpuDetailDTO findSpuDetailBySpuId(@RequestParam("id") Long id);

    // 根据SpuId查询Sku集合
    @GetMapping("/sku/of/spu")
    public List<SkuDTO> findSkusBySpuId(@RequestParam("id") Long id);

    //根据规格组查询规格参数
    @GetMapping("/spec/params")
    public List<SpecParamDTO> findSpecParam(@RequestParam(value = "gid", required = false) Long gid,
                                            @RequestParam(value = "cid", required = false) Long cid,
                                            @RequestParam(value = "searching", required = false) Boolean searching);

    //根据分类id的集合查询分类对象的集合
    @GetMapping("/category/list")
    public List<CategoryDTO> findByCategorysByIds(@RequestParam("ids") List<Long> ids);

    //根据品牌id查询品牌对象
    @GetMapping("/brand/{id}")
    public BrandDTO findBrandById(@PathVariable("id") Long id);

    //根据spuId查询Spu对象，要给对象中的sku集合和detail对象赋值
    @GetMapping("/spu/{id}")
    public SpuDTO findSpuBySpuId(@PathVariable("id") Long id);
    //根据spu中第三级商品分类查询出规格组集合及其下规格参数集合
    @GetMapping("/spec/groups/of/category/params")
    public List<SpecGroupDTO> findSpecGroupWithParamsByCid(@RequestParam("id") Long id);

    //在item微服务提供根据sku的id集合查询sku的对象集合的处理
    @GetMapping("/sku/list")
    public List<SkuDTO> findSkusBySkuIds(@RequestParam("ids") List<Long> ids);

    /**
     * 减库存
     */
    @PutMapping("/stock/minus")
    public Void minusStock(@RequestBody Map<Long, Integer> map);
}




